﻿//#include <iostream>
#include <Windows.h>
#include "stdio.h"
#include "div.h"
#include "add.h"
#include "sub.h"
#include "mul.h"
int divv(int a, int b)
{
	if (b == 0)
	{
		printf("输入除数错误\r\n");
		return 0;
	}
	if ((a == INT_MIN) && (b == -1))
	{
		printf("输出溢出\r\n");
		return 0;
	}
	return a / b;
}
typedef int (*LPDO_ARRAY)(int a, int b);
int main()
{
	int a = 8;
	int b = 2;
	int sum = 0;
	int su = 0;
	int di = 0;
	sum = add(a, b);
	su = sub(a, b);
	di = divv(a, b);
	HINSTANCE hDll;//定义一个实例句柄，引用动态库
	LPDO_ARRAY lpDo_array;
	//第二步，加载DemoDll.dll动态库文件
	hDll = LoadLibrary(L"mul.dll");
	if (hDll != NULL)
	{
		lpDo_array = (LPDO_ARRAY)GetProcAddress(hDll, "mul");
		if (lpDo_array != NULL)
		{
			int nRet = 0;
			nRet = lpDo_array(a, b);
			//std::cout << "返回值：" << nRet << std::endl;
			printf("%d\n", nRet);
		}
		FreeLibrary(hDll);
	}
	printf("%d\n", sum);
	printf("%d\n", su);
	printf("%d\n", di);


	return 0;
}
